{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=50
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
var  	
	i,aa,bb,kk,ha,hb,ta,tb,x,y:longint;
	a,b:array[0..2000010] of longint;
	f:boolean;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
for i:=1 to 5 do
	read(a[i]);
aa:=5;
bb:=5;
for i:=1 to 5 do
	read(b[i]);
kk:=0;
ha:=1;
ta:=5;
hb:=1;
tb:=5;
while (kk<1000000) and (aa>0) and (bb>0) do begin
	inc(kk);
	x:=a[ha];
	y:=b[hb];
	inc(ha);
	inc(hb);
	if (x=0) and (y=9) then f:=true else
	if (y=0) and (x=9) then f:=false else
	if x>y then f:=true else
	if y>x then f:=false;
	if f then begin
		inc(ta,2);
		a[ta-1]:=x;
		a[ta]:=y;
	end else begin
		inc(tb,2);
		b[tb-1]:=x;
		b[tb]:=y;
	end;
	aa:=ta-ha+1;
	bb:=tb-hb+1;
end;
if aa=0 then write('second ',kk) else
if bb=0 then write('first ',kk) else write('botva');
end.